#pragma once

template<class Iterator,class Ref,class Ptr>
class ReverseIterator
{
public:
	typedef ReverseIterator<Iterator , Ref , Ptr> self;

	Iterator cur;
	

	ReverseIterator(Iterator it)
		:cur(it)
	{}
	

	self& operator++()
	{
		--cur;
		return *this;
	}

	self operator++(int)
	{
		iterator tmp = cur;
		--cur;
		return *tmp;
	}

	self& operator--()
	{
		++cur;
		return *this;
	}

	self operator--(int)
	{
		iterator tmp = cur;
		++cur;
		return *tmp;
	}

	Ref operator*()
	{
		ReverseIterator tmp = cur;
		return *--tmp;
	}

	Ptr operator->()
	{
		return &(operator*());
	}
	
	bool operator!=(Iterator it)
	{
		return  it != cur;
	}

	bool operator==(Iterator it)
	{
		return it == cur;
	}
};